//
// Created by liushuai on 2021/1/14.
//

#include "isPail.h"
bool isPail(ListNode* head){
    int flag = true;
    if(!head)
        return flag;
    else{
        std::stack<ListNode*> result;
        ListNode* current = head;
        while (current){
            result.push(current);
            current = current->next;
        }
        while (!result.empty()){
            ListNode* node = result.top();
            result.pop();
            if(node->val == head->val){
                node = node->next;
                head = head->next;
            } else
                flag = false;
        }
        return flag;
    }
}
